<?php
class Schedule_model extends CI_Model {
    public function __construct() {
        parent::__construct();
    }
    
    public function buildSchedule($path_id, $member_id, $_date) {
        $sql_insertSchedule = "INSERT INTO schedule(member_id, learning_path_id, created_date, start_date, end_date)
                VALUES (" . $member_id . ", " . $path_id . ", now(), \"\", \"\")";
        $this->db->query($sql_insertSchedule);
        $insertedScheduleID = $this->db->insert_id();
        foreach($_date as $id => $d) {
            $sql_insertScheduleDetail = "INSERT INTO schedule_detail(schedule_id, type_schedule, carry_out_date, task)
                VALUES ('".$insertedScheduleID."', 1, '".$d."', '".$id."')";
            print($sql_insertScheduleDetail . "\n");
            $this->db->query($sql_insertScheduleDetail);
        }
    }
}
?>
